package edu.hawaii.duedates.datastore;

import edu.hawaii.duedates.libraries.ILibrary;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * Stores information about users.
 * 
 * @author Daniel Arakaki, Arthur Shum, Daniel Tian, Jeho Jung
 */
public class User implements Serializable {

  /** Support serialization. */
  private static final long serialVersionUID = 1L;

  private final String name;
  private final String email;
  private final String password;

  /** This user's list of libraries. */
  private final List<ILibrary> libraryList = new ArrayList<ILibrary>();
  
  /**
   * Constructs a User object.
   * 
   * @param name This user's name.
   * @param email This user's email.
   * @param password This user's password.
   */
  public User(String name, String email, String password) {
    this.name = name;
    this.email = email;
    this.password = password;
  }
  
  /**
   * Checks if a given email and password match those of this user's.
   * 
   * @param email The email to check.
   * @param password The password to check.
   * @return True if email and password match, false otherwise.
   */
  public boolean isValidUser(String email, String password) {
    return (this.email.equalsIgnoreCase(email) && this.password.equals(password));      
  }

  /**
   * Returns this user's name.
   * 
   * @return this user's name.
   */
  public String getName() {
    return this.name;
  }

  /**
   * Returns this user's email.
   * 
   * @return this user's email.
   */
  public String getEmail() {
    return this.email;
  }
  
  /**
   * Returns this user's list of libraries.
   * 
   * @return This user's list of libraries.
   */
  public List<ILibrary> getLibraryList() {
    return this.libraryList;
  }
  
  /**
   * Add a given library to this user's list of libraries.
   * 
   * @param library The library to add to this user's list of libraries.
   */
  public void addLibrary(ILibrary library) {
    this.libraryList.add(library);
  }

}
